package com.example.svetlofor;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.RelativeLayout;
import android.widget.TextView;

public class SvetloforActivity extends Activity implements OnClickListener {

	TextView tvInfo;
	RelativeLayout layout;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_svetlofor);

		layout = (RelativeLayout) findViewById(R.id.relatuveLayout);
		tvInfo = (TextView) findViewById(R.id.textView);

		Button redButton = (Button) findViewById(R.id.buttonRed);
		Button yellowButton = (Button) findViewById(R.id.buttonYellow);
		Button greenButton = (Button) findViewById(R.id.buttonGreen);
		Button aboutButton = (Button) findViewById(R.id.buttonAbout);
		Button thirdActButton = (Button) findViewById(R.id.buttonThirdActivity);

		redButton.setOnClickListener(this);
		yellowButton.setOnClickListener(this);
		greenButton.setOnClickListener(this);
		aboutButton.setOnClickListener(this);
		thirdActButton.setOnClickListener(this);
	}
	

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.activity_svetlofor, menu);
		return true;
	}

	public void buttonRed_click(View view) {
		tvInfo.setText(R.string.red);
		layout.setBackgroundResource(R.color.redColor);
	}

	public void buttonGreen_click(View view) {
		tvInfo.setText(R.string.green);
		layout.setBackgroundResource(R.color.greenColor);

	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.buttonRed:
			tvInfo.setText(R.string.red);
			layout.setBackgroundResource(R.color.redColor);
			break;
		case R.id.buttonYellow:
			tvInfo.setText(R.string.yellow);
			layout.setBackgroundResource(R.color.yellowColor);
			break;
		case R.id.buttonGreen:
			tvInfo.setText(R.string.green);
			layout.setBackgroundResource(R.color.greenColor);
			break;
		case R.id.buttonAbout:
			Intent aboutIntent = new Intent(SvetloforActivity.this,
					AboutActivity.class);
			startActivity(aboutIntent);
			break;
		case R.id.buttonThirdActivity:
			Intent thirdActIntent = new Intent(SvetloforActivity.this,
					SecondActivity.class);
			startActivity(thirdActIntent);
			break;
		}

	}

}
